package com.four.dailymanage.repair.controller;

import com.four.dailymanage.common.bean.ResponseData;
import com.four.dailymanage.common.controller.BaseController;
import com.four.dailymanage.repair.entity.RepairApply;
import com.four.dailymanage.repair.service.RepairApplyService;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@AllArgsConstructor
@NoArgsConstructor
@RequestMapping("/repairApply")
public class RepairApplyController extends BaseController {
    @Autowired
    RepairApplyService repairApplyService;

    //申请维修
    @PostMapping("/insert")
    public ResponseData<Boolean> insertApply(@RequestBody RepairApply repairApply){
        return  returnBoolean(repairApplyService.insert(repairApply));
    }

    //分页
    @GetMapping("/getAll")
    public ResponseData<Object>  getAll(
            @RequestParam("pageNum") int pageNum,
            @RequestParam("pageSize") int pageSize,
            @RequestParam(value = "sname",required = false) String sname,
            @RequestParam(value = "content",required = false) String content,
            @RequestParam(value = "repairDt",required = false) String repairDt,
            @RequestParam(value = "status",required = false) String status,
            @RequestParam(value = "repairMan",required = false) String repairMan

    ){
        return returnObject(repairApplyService.getPageRepairApply(pageNum, pageSize, sname, content, repairDt,status,repairMan));
    }

    //更新状态可撤销
    @PutMapping("/updateS")
    public  ResponseData<Boolean> updateS(@RequestBody RepairApply repairApply){
        return returnBoolean(repairApplyService.updateStatus(repairApply));
    }
   //接单
    @PutMapping("/receive")
    public  ResponseData<Boolean> receive(@RequestBody RepairApply repairApply){
        return returnBoolean(repairApplyService.updateReceive(repairApply));
    }
    //拒单
    @PutMapping("/reject")
    public  ResponseData<Boolean> reject(@RequestBody RepairApply repairApply){
        return returnBoolean(repairApplyService.updateReject(repairApply));
    }
    //维修
    @PutMapping("/repair")
    public  ResponseData<Boolean> repair(@RequestBody RepairApply repairApply){
        return returnBoolean(repairApplyService.updateRepair(repairApply));
    }

}
